<template>
  <el-breadcrumb separator="/">
    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item v-for="(item, index) in breadcrumbs"
                        :key="index">
      {{ item.meta.title }}
    </el-breadcrumb-item>
  </el-breadcrumb>
</template>


<script setup lang="ts">
import {useRoute} from "vue-router";
import {computed} from "vue";

const route=useRoute()
// 逻辑代码
const breadcrumbs = computed(() => {
  //route 表示当前路由的一些信息
  return route.matched.filter((item) => {
    if(item.meta?.title!=='首页') return item.meta?.title
  }) // 过滤有效路由记录
})
</script>

<style scoped>

</style>
